'use strict';
/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  /**
   * 后台管理
   */
  router.post('/api/upload/file', controller.uploadcos.file);
  router.post('/api/upload/file2', controller.uploadcos.file);

  /**
   * 用户权限相关
   */
  router.post('/api/user/login', controller.user.login);
  router.post('/api/user/register', controller.user.register);
  router.get('/api/user/list', controller.user.allList);
  router.get('/api/user/simpleList', controller.user.simpleList);
  router.post('/api/user/updateUserRoles', controller.user.updateUserRoles);
  router.get('/api/user/getUserRoles', controller.user.getUserRoles);
  router.get('/api/user/getUserInfo', controller.user.getUserInfo);
  router.resources('user', '/api/user', controller.user);
  router.get('/api/role/list', controller.role.allList);
  router.resources('role', '/api/role', controller.role);
  router.get('/api/menu/list', controller.menu.allList);
  router.resources('menu', '/api/menu', controller.menu);
  router.get('/api/policy/list', controller.policy.allList);
  router.resources('policy', '/api/policy', controller.policy);
  /**
   * 闲置物资设备平台相关
   */
  // 分类管理
  router.get('/api/idleCategory/tree', controller.idleCategory.tree);
  router.get('/api/idleCategory/getByType', controller.idleCategory.getByType);
  router.get('/api/idleCategory/getSubTypes', controller.idleCategory.getSubTypes);
  router.resources('idleCategory', '/api/idleCategory', controller.idleCategory);

  // 物资/设备管理
  router.get('/api/idleItem/nearby', controller.idleItem.nearby);
  router.post('/api/idleItem/batchImport', controller.idleItem.batchImport);
  router.get('/api/idleItem/excelTemplate', controller.idleItem.getExcelTemplate);
  router.get('/api/idleItem/myItems', controller.idleItem.myItems);
  router.post('/api/idleItem/status', controller.idleItem.updateIdleItemStatus);
  router.get('/api/idleItem/adminPage', controller.idleItem.adminPage)

  router.post('/api/idleItem/bathDelete', controller.idleItem.bathDelete);

  router.get('/api/idleItem/userStats', controller.idleItem.getUserDeviceStats);
  router.get('/api/idleItem/systemStats', controller.idleItem.getSystemDeviceStats);
  router.get('/api/idleTransfer/stats', controller.idleItem.getTransferStats);


  router.resources('idleItem', '/api/idleItem', controller.idleItem);

  // 调拨管理
  router.post('/api/idleTransfer/apply', controller.idleTransfer.apply);
  router.post('/api/idleTransfer/approve', controller.idleTransfer.approve);
  router.post('/api/idleTransfer/cancel', controller.idleTransfer.cancel);
  router.get('/api/idleTransfer/myApplies', controller.idleTransfer.myApplies);
  router.get('/api/idleTransfer/myApprovals', controller.idleTransfer.myApprovals);
  router.get('/api/idleTransfer/statistics', controller.idleTransfer.statistics);
  router.resources('idleTransfer', '/api/idleTransfer', controller.idleTransfer);

  // 收藏管理
  router.post('/api/idleFavorite/toggle', controller.idleFavorite.toggle);
  router.get('/api/idleFavorite/myFavorites', controller.idleFavorite.myFavorites);
  router.get('/api/idleFavorite/check', controller.idleFavorite.check);
  router.resources('idleFavorite', '/api/idleFavorite', controller.idleFavorite);

  router.get('/api/city/tree', controller.idleCity.tree);
};
